package drone.basis.util ;

import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.text.SimpleDateFormat ;
import java.util.Arrays ;
import java.util.Calendar ;
import java.util.Date ;
import java.util.LinkedList ;
import java.util.List ;
import java.util.Objects ;

import drone.basis.GlobalConfig ;

public class DateUtil
{

	public static final Long DAY = new Long ( 24 * 60 * 60 * 1000 ) ;

	public static final Long HOUR = new Long ( 60 * 60 * 1000 ) ;

	public static final Long MINUTE = new Long ( 60 * 1000 ) ;

	public static final Long SECOND = new Long ( 1000 ) ;

	public final static String PARTYEAR = "yyyy" ;

	public final static String PARTMONTH = "MM" ;

	public final static String PARTDAY = "dd" ;

	public final static String PARTHOUR = "HH" ;

	public final static String PARTMINUTE = "mm" ;

	public final static String PARTSECOND = "ss" ;

	public final static String DATEHOUR = "yyyy-MM-dd HH" ;

	public final static String DATEMIN = "yyyy-MM-dd HH:mm" ;

	public final static String DATETIME = "yyyy-MM-dd HH:mm:ss" ;

	public final static String DATE = "yyyy-MM-dd" ;

	public final static String CNDATE = "yyyy年MM月dd日" ;

	public final static String DATEYEAR = "yyyy" ;

	public final static String CNDATEYEAR = "yyyy年" ;

	public final static String DATEMONTH = "yyyy-MM" ;

	public final static String CNDATEMONTH = "yyyy年MM月" ;

	public final static String DATEDAY = "MM-dd" ;

	public final static String CNDATEDAY = "MM月dd日" ;

	public final static String TIME = "HH:mm:ss" ;

	public final static String TIMEMIN = "HH:mm" ;

	public final static String MINSECOND = "mm:ss" ;

	public final static String DATETIMESHORT = "yyMMddHHmmss" ;

	public final static String DATETIMENOSPACE = "yyyyMMddHHmmss" ;

	public final static String DATENOSPACE = "yyyyMMdd" ;

	public final static String TIMENOSPACE = "HHmmss" ;

	public final static String CARDEXPIRE = "yyMM" ;

	public final static String DATEWITHDOT = "yyyy.MM.dd" ;

	public static Date parse (
			String source
	)
	{
		return parse ( source , DATETIME ) ;
	}

	public static Date parse (
			Long time
	)
	{

		return parse ( time , DATETIME ) ;
	}

	public static Date parse (
			String source ,
			String pattern
	)
	{

		if ( StringUtil.isEmpty ( source ) )
		{
			return null ;
		}
		try
		{
			return new SimpleDateFormat ( pattern ).parse ( source ) ;
		} catch ( Exception e )
		{
			return null ;
		}
	}

	public static Date parse (
			Long time ,
			String pattern
	)
	{
		if ( Objects.isNull ( time ) || time.longValue ( ) < 0 )
		{
			return null ;
		}
		try
		{
			return new Date ( time ) ;
		} catch ( Exception e )
		{
			return null ;
		}
	}

	public static String format ( )
	{
		return format ( new Date ( ) , DATETIME ) ;
	}

	public static String format (
			Date source
	)
	{
		return format ( source , DATETIME ) ;
	}

	public static String format (
			Date source ,
			String pattern
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return null ;
		}
		return new SimpleDateFormat ( pattern ).format ( source ) ;
	}

	// 格式化间隔时间
	public static String count (
			Long source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return null ;
		}

		Long day = source / DAY ;

		Long hour = ( source - ( day * DAY ) ) / HOUR ;

		Long minute = ( source - ( day * DAY ) - ( hour * HOUR ) ) / MINUTE ;

		// Long second = ( source - ( day * DAY ) - ( hour * HOUR ) - ( minute *
		// MINUTE ) ) / SECOND ;

		return String.format ( "%s天%s时%s分" , String.valueOf ( day ) , String.valueOf ( hour ) , String.valueOf ( minute ) ) ;

	}

	public static List < Date > combo (
			String date1 ,
			String date2
	)
	{
		return combo ( parse ( date1 , DATE ) , parse ( date2 , DATE ) ) ;
	}

	public static List < Date > combo (
			Date date1 ,
			Date date2
	)
	{
		if ( Objects.isNull ( date1 ) && Objects.isNull ( date2 ) )
		{
			return null ;
		}
		return Arrays.asList ( new Date [ ]
		{
				DateUtil.minOfDay ( date1 ) ,
				DateUtil.maxOfDay ( date2 )
		} ) ;
	}

	// 是否是日期
	public static boolean isDate (
			Object object
	)
	{
		if ( Objects.isNull ( object ) )
		{
			return false ;
		}
		try
		{
			new SimpleDateFormat ( DATE ).parse ( object.toString ( ) ) ;
			return true ;
		} catch ( Exception e )
		{
			return false ;
		}
	}

	// 是否整分
	public static boolean pointMin (
			Date source
	)
	{
		BigDecimal res = NumberUtil.div ( new BigDecimal ( source.getTime ( ) ) , new BigDecimal ( GlobalConfig.MINUTE ) ) ;
		try
		{
			Integer.parseInt ( res.stripTrailingZeros ( ).toPlainString ( ) ) ;
			return true ;
		} catch ( Exception e )
		{
			return false ;
		}

	}

	// 是否整分
	public static boolean pointHour (
			Date source
	)
	{
		BigDecimal res = NumberUtil.div ( new BigDecimal ( source.getTime ( ) ) , new BigDecimal ( GlobalConfig.HOUR ) ) ;
		try
		{
			Integer.parseInt ( res.stripTrailingZeros ( ).toPlainString ( ) ) ;
			return true ;
		} catch ( Exception e )
		{
			return false ;
		}
	}

	// 是否整天
	public static boolean pointDay (
			Date source
	)
	{

		BigDecimal res = NumberUtil.div ( new BigDecimal ( source.getTime ( ) ) , new BigDecimal ( GlobalConfig.HOUR ) ) ;
		try
		{
			Integer.parseInt ( res.stripTrailingZeros ( ).toPlainString ( ) ) ;
			if ( format ( source ).endsWith ( "00:00:00" ) )
			{
				return true ;
			} else
			{
				return false ;
			}
		} catch ( Exception e )
		{
			return false ;
		}

	}

	// 是否闰年
	public static boolean leapYear (
			int year
	)
	{
		return ( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 ) ;
	}

	// 根据一个日期，返回是星期几的字符串
	public static String weekNumber (
			Date source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return "" ;
		}
		Calendar c = Calendar.getInstance ( ) ;
		c.setTime ( source ) ;
		return new SimpleDateFormat ( "EEEE" ).format ( c.getTime ( ) ) ;
	}

	// 日期转16进制
	public static String stampHex (
			Date source
	)
	{
		if ( source == null )
		{
			return null ;
		}
		return Long.toHexString ( source.getTime ( ) / SECOND ) ;
	}

	// 日期转16进制
	public static Date hexStamp (
			String source
	)
	{
		if ( source == null )
		{
			return null ;
		}
		return new Date ( Long.parseLong ( source , 16 ) * SECOND ) ;
	}

	// 取某个日期的00:00:00
	public static Date minOfDay (
			Date source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return new Date ( 0L ) ;
		}
		return parse ( format ( source , DATE ) + " 00:00:00" , DATETIME ) ;
	}

	// 取某个日期的第二天的00:00:00
	public static Date maxOfDay (
			Date source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return new Date ( ) ;
		}
		return DateUtil.minOfDay ( intervalDay ( source , 1 ) ) ;
	}

	// 取某个日期当月一号的00:00:00
	public static Date minOfMonth (
			Date source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return new Date ( 0L ) ;
		}
		Calendar cal = Calendar.getInstance ( ) ;
		cal.setTime ( source ) ;
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		cal.set ( Calendar.HOUR_OF_DAY , 0 ) ;
		cal.set ( Calendar.MINUTE , 0 ) ;
		cal.set ( Calendar.SECOND , 0 ) ;
		cal.set ( Calendar.MILLISECOND , 0 );
		return cal.getTime ( ) ;
	}

	// 取某个日期的下个月月的第一天的00:00:00
	public static Date maxOfMonth (
			Date source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return new Date ( ) ;
		}

		Calendar cal = Calendar.getInstance ( ) ;
		cal.setTime ( source ) ;
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		cal.add ( Calendar.MONTH , 1 ) ;// 加一个月，变为下月的1号
		cal.set ( Calendar.HOUR_OF_DAY , 0 ) ;
		cal.set ( Calendar.MINUTE , 0 ) ;
		cal.set ( Calendar.SECOND , 0 ) ;
		cal.set ( Calendar.MILLISECOND , 0 );
		return cal.getTime ( ) ;

	}

	// 取某个日期当月一号的00:00:00
	public static Date minOfYear (
			Date source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return new Date ( 0L ) ;
		}
		Calendar cal = Calendar.getInstance ( ) ;
		cal.setTime ( source ) ;
		cal.set ( Calendar.MONTH , 0 ) ;// 设为第一个月
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		cal.set ( Calendar.HOUR_OF_DAY , 0 ) ;
		cal.set ( Calendar.MINUTE , 0 ) ;
		cal.set ( Calendar.SECOND , 0 ) ;
		cal.set ( Calendar.MILLISECOND , 0 );
		return cal.getTime ( ) ;
	}

	// 取某个日期的下个月月的第一天的00:00:00
	public static Date maxOfYear (
			Date source
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return new Date ( ) ;
		}

		Calendar cal = Calendar.getInstance ( ) ;
		cal.setTime ( source ) ;
		cal.set ( Calendar.MONTH , 0 ) ;// 设为第一个月
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		cal.add ( Calendar.YEAR , 1 ) ;// 加1年
		cal.set ( Calendar.HOUR_OF_DAY , 0 ) ;
		cal.set ( Calendar.MINUTE , 0 ) ;
		cal.set ( Calendar.SECOND , 0 ) ;
		cal.set ( Calendar.MILLISECOND , 0 );
		return cal.getTime ( ) ;

	}

	// 将某个日期取整,单位毫秒,四舍五入half_even
	public static Date round (
			Date source ,
			long time
	)
	{
		if ( Objects.isNull ( source ) || time <= 0 )
		{
			return null ;
		}

		BigDecimal div = NumberUtil.div ( new BigDecimal ( source.getTime ( ) ) , new BigDecimal ( time ) ).setScale ( 0 , RoundingMode.FLOOR ) ;

		BigDecimal sub = NumberUtil.mul ( div , new BigDecimal ( time ) ).setScale ( 0 , RoundingMode.FLOOR ) ;

		return new Date ( sub.longValue ( ) ) ;
	}

	// 将某个日期按5分钟取整
	public static Date round5min (
			Date source
	)
	{
		return roundMin ( source , 5 ) ;
	}

	// 将某个日期按单位分钟取整,大于source日期则前补mins分钟
	public static Date roundMin (
			Date source ,
			int mins
	)
	{
		if ( Objects.isNull ( source ) || mins <= 0 )
		{
			return null ;
		}
		return new Date ( source.getTime ( ) - source.getTime ( ) % ( MINUTE * mins ) + ( MINUTE * mins ) ) ;
	}

	// 将某个日期按小时取整,大于source日期则前补hours小时
	public static Date roundHour (
			Date source ,
			int hours
	)
	{
		if ( Objects.isNull ( source ) || hours <= 0 )
		{
			return null ;
		}
		return new Date ( source.getTime ( ) - source.getTime ( ) % ( HOUR * hours ) + ( HOUR * hours ) ) ;
	}

	// 得到某个日期和现在的间隔时间
	public static Long distance (
			Date source
	)
	{
		return distance ( source , new Date ( ) ) ;
	}

	// 得到两个日期间的间隔时间
	public static Long distance (
			Date date1 ,
			Date date2
	)
	{
		if ( Objects.isNull ( date1 ) || Objects.isNull ( date2 ) )
		{
			return null ;
		}

		return Math.abs ( date1.getTime ( ) - date2.getTime ( ) ) ;
	}

	// 得到某个日期和现在的间隔秒数
	public static Long distanceSeconds (
			Date source
	)
	{
		return distanceSeconds ( source , new Date ( ) ) ;
	}

	// 得到两个日期间的间隔秒数
	public static Long distanceSeconds (
			Date date1 ,
			Date date2
	)
	{
		if ( Objects.isNull ( date1 ) || Objects.isNull ( date2 ) )
		{
			return null ;
		}
		Long second = ( date1.getTime ( ) - date2.getTime ( ) ) / SECOND ;
		return Math.abs ( second ) ;
	}

	// 得到某个日期和现在的间隔小时
	public static Long distanceHours (
			Date source
	)
	{
		return distanceHours ( source , new Date ( ) ) ;
	}

	// 得到两个日期间的间隔天数
	public static Long distanceHours (
			Date date1 ,
			Date date2
	)
	{
		if ( Objects.isNull ( date1 ) || Objects.isNull ( date2 ) )
		{
			return null ;
		}
		Long hour = ( date1.getTime ( ) - date2.getTime ( ) ) / HOUR ;
		return Math.abs ( hour ) ;
	}

	// 得到某个日期和现在的间隔天数
	public static Long distanceDays (
			Date source
	)
	{
		return distanceDays ( source , new Date ( ) ) ;
	}

	// 得到两个日期间的间隔天数
	public static Long distanceDays (
			Date date1 ,
			Date date2
	)
	{
		if ( Objects.isNull ( date1 ) || Objects.isNull ( date2 ) )
		{
			return null ;
		}
		Long day = ( date1.getTime ( ) - date2.getTime ( ) ) / DAY ;
		return Math.abs ( day ) ;
	}

	// 返回间距N分钟的日期
	public static Date intervalMin (
			int min
	)
	{
		return intervalMin ( new Date ( ) , min ) ;
	}

	// 返回间距某日期N分钟的日期
	public static Date intervalMin (
			Date source ,
			int min
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return null ;
		}
		Calendar c = Calendar.getInstance ( ) ;
		c.setTime ( source ) ;
		c.add ( Calendar.MINUTE , min ) ;
		Date date = c.getTime ( ) ;
		return date ;
	}

	// 返回间距N小时的日期
	public static Date intervalHour (
			int hours
	)
	{
		return intervalHour ( new Date ( ) , hours ) ;
	}

	// 返回间距某日期N小时的日期
	public static Date intervalHour (
			Date source ,
			int hours
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return null ;
		}
		Calendar c = Calendar.getInstance ( ) ;
		c.setTime ( source ) ;
		c.add ( Calendar.HOUR , hours ) ;
		Date date = c.getTime ( ) ;
		return date ;
	}

	// 返回间距N天的日期
	public static Date intervalDay (
			int days
	)
	{
		return intervalDay ( new Date ( ) , days ) ;
	}

	// 返回间距某日期N天的日期
	public static Date intervalDay (
			Date source ,
			int days
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return null ;
		}
		Calendar c = Calendar.getInstance ( ) ;
		c.setTime ( source ) ;
		c.add ( Calendar.DATE , days ) ;
		Date date = c.getTime ( ) ;
		return date ;
	}

	// 返回间距N月的日期
	public static Date intervalMonth (
			int months
	)
	{
		return intervalMonth ( new Date ( ) , months ) ;
	}

	// 返回间距某月N月的日期
	public static Date intervalMonth (
			Date source ,
			int months
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return null ;
		}
		Calendar c = Calendar.getInstance ( ) ;
		c.setTime ( source ) ;
		c.add ( Calendar.MONTH , months ) ;
		Date date = c.getTime ( ) ;
		return date ;
	}

	// 返回间距N年的日期
	public static Date intervalYear (
			int years
	)
	{
		return intervalYear ( new Date ( ) , years ) ;
	}

	// 返回间距某年N年的日期
	public static Date intervalYear (
			Date source ,
			int years
	)
	{
		if ( Objects.isNull ( source ) )
		{
			return null ;
		}
		Calendar c = Calendar.getInstance ( ) ;
		c.setTime ( source ) ;
		c.add ( Calendar.YEAR , years ) ;
		Date date = c.getTime ( ) ;
		return date ;
	}

	// 获取当月第一天
	public static Date firstDayOfMonth ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		return cal.getTime ( ) ;
	}

	// 计算当月最后一天,返回字符串
	public static Date lastDayOfMonth ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		cal.add ( Calendar.MONTH , 1 ) ;// 加一个月，变为下月的1号
		cal.add ( Calendar.DATE , - 1 ) ;// 减去一天，变为当月最后一天
		return cal.getTime ( ) ;
	}

	// 上月第一天
	public static Date firstDayOfPreviousMonth ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		cal.add ( Calendar.MONTH , - 1 ) ;// 减一个月
		return cal.getTime ( ) ;
	}

	// 获得上月最后一天的日期
	public static Date lastDayOfPreviousMonth ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DATE , 1 ) ;// 设为当前月的1号
		cal.add ( Calendar.DATE , - 1 ) ;// 减一天
		return cal.getTime ( ) ;
	}

	// 获得下个月第一天的日期
	public static Date firstDayOfNextMonth ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.add ( Calendar.MONTH , 1 ) ;// 加一个月
		cal.set ( Calendar.DATE , 1 ) ;// 把日期设置为当月第一天
		return cal.getTime ( ) ;
	}

	// 获得下个月最后一天的日期
	public static Date lastDayOfNextMonth ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.add ( Calendar.MONTH , 2 ) ;// 加两个月
		cal.set ( Calendar.DATE , 1 ) ;// 把日期设置为当月第一天
		cal.add ( Calendar.DATE , - 1 ) ;// 把日期设置为当月第一天
		return cal.getTime ( ) ;
	}

	// 获取当年第一天
	public static Date firstDayOfYear ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DAY_OF_YEAR , 1 ) ;// 设为当前年的1号
		return cal.getTime ( ) ;
	}

	// 计算当年最后一天,返回字符串
	public static Date lastDayOfYear ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DAY_OF_YEAR , 1 ) ;// 设为当前年的1号
		cal.add ( Calendar.YEAR , 1 ) ;// 加一个年，变为下年的1号
		cal.add ( Calendar.DATE , - 1 ) ;// 减去一天，变为当年最后一天
		return cal.getTime ( ) ;
	}

	// 上年第一天
	public static Date firstDayOfPreviousYear ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DAY_OF_YEAR , 1 ) ;// 设为当前年的1号
		cal.add ( Calendar.YEAR , - 1 ) ;// 减一个年
		return cal.getTime ( ) ;
	}

	// 获得上年最后一天的日期
	public static Date lastDayOfPreviousYear ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.set ( Calendar.DAY_OF_YEAR , 1 ) ;// 设为当前年的1号
		cal.add ( Calendar.DATE , - 1 ) ;// 减一天
		return cal.getTime ( ) ;
	}

	// 获得下个年第一天的日期
	public static Date firstDayOfNextYear ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.add ( Calendar.YEAR , 1 ) ;// 加一个年
		cal.set ( Calendar.DAY_OF_YEAR , 1 ) ;// 把日期设置为当年第一天
		return cal.getTime ( ) ;
	}

	// 获得下个年最后一天的日期
	public static Date lastDayOfNextYear ( )
	{
		Calendar cal = Calendar.getInstance ( ) ;
		cal.add ( Calendar.YEAR , 2 ) ;// 加两个年
		cal.set ( Calendar.DAY_OF_YEAR , 1 ) ;// 把日期设置为当年第一天
		cal.add ( Calendar.DATE , - 1 ) ;// 减一天
		return cal.getTime ( ) ;
	}

	// 得到两个日期间的日集合
	public static List < String > collectDays (
			String min
	)
	{
		return collectDays ( min , format ( new Date ( ) , DATE ) ) ;
	}

	// 得到两个日期间的日集合
	public static List < String > collectDays (
			String min ,
			String max
	)
	{

		Date minDate = parse ( min , DATE ) ;
		Date maxDate = parse ( max , DATE ) ;
		List < String > result = new LinkedList < String > ( ) ;

		while ( maxDate.after ( minDate ) )
		{
			maxDate = intervalDay ( maxDate , - 1 ) ;
			result.add ( format ( maxDate , DATE ) ) ;
		}
		return result ;
	}

	// 得到两个日期间的月集合
	public static List < String > collectMonths (
			String min
	)
	{
		return collectMonths ( min , format ( new Date ( ) , DATEMONTH ) ) ;
	}

	// 得到两个日期间的月集合
	public static List < String > collectMonths (
			String min ,
			String max
	)
	{

		Date minDate = parse ( min , DATEMONTH ) ;
		Date maxDate = parse ( max , DATEMONTH ) ;

		List < String > result = new LinkedList < String > ( ) ;

		while ( maxDate.after ( minDate ) )
		{
			maxDate = intervalMonth ( maxDate , - 1 ) ;
			result.add ( format ( maxDate , DATEMONTH ) ) ;
		}

		return result ;
	}

	// 得到两个日期间的年集合
	public static List < String > collectYears (
			String min
	)
	{
		return collectYears ( min , format ( new Date ( ) , DATEYEAR ) ) ;
	}

	// 得到两个日期间的年集合
	public static List < String > collectYears (
			String min ,
			String max
	)
	{

		Date minDate = parse ( min , DATEYEAR ) ;
		Date maxDate = parse ( max , DATEYEAR ) ;

		List < String > result = new LinkedList < String > ( ) ;

		while ( maxDate.after ( minDate ) )
		{
			maxDate = intervalYear ( maxDate , - 1 ) ;
			result.add ( format ( maxDate , DATEYEAR ) ) ;
		}

		return result ;
	}

	public static void main (
			String [ ] args
	)
	{

		String date = "2021-03-18 00:00:00" ;

		Date testDate = DateUtil.parse ( date ) ;

		Date resDate = round ( testDate , 24 * 60 * 60 * 1000 ) ;

		System.out.println ( DateUtil.format ( resDate ) ) ;

		// List < String > result = collectMonths ( "2020-01" ) ;
		//
		// for ( String d : result )
		// {
		// System.out.println ( d ) ;
		// }

		// System.out.println ( count ( new Date ( ).getTime ( ) -
		// 1606710827509L ) ) ;
		//
		// String s = "2020-05-20 01:00:00.0" ;
		// Date d = parse ( s ) ;
		//
		// System.out.println ( pointDay ( d ) ) ;
		//
		// Long t = distance ( d ) ;
		// System.out.println ( t ) ;
		//
		// System.out.println ( count ( 1606710827509L ) ) ;

		// System.out.println ( maxOfDay ( new Date ( ) ) ) ;
		//
		// System.out.println ( "是否闰年:" + leapYear ( 2017 ) ) ;
		// System.out.println ( "根据日期返回周几:" + weekNumber ( intervalDay ( - 1 ) )
		// ) ;
		//
		// System.out.println ( "获取某天的最开始:" + DateUtil.format (
		// DateUtil.minOfDay ( intervalDay ( - 1 ) ) ) ) ;
		// System.out.println ( "获取某天的最结尾:" + DateUtil.format (
		// DateUtil.maxOfDay ( intervalDay ( - 1 ) ) ) ) ;
		// System.out.println ( "获取昨天的日期:" + DateUtil.format ( intervalDay ( - 1
		// ) ) ) ;
		// System.out.println ( "获取明天的日期:" + DateUtil.format ( intervalDay ( 1 )
		// ) ) ;
		// System.out.println ( "获取7天后的日期:" + DateUtil.format ( intervalDay ( 7
		// ) ) ) ;
		// System.out.println ( "获取7天前的日期:" + DateUtil.format ( intervalDay ( -
		// 7 ) ) ) ;
		// System.out.println ( "获取两个日期间隔的天数:" + distanceDays ( intervalDay ( 2
		// ) , intervalDay ( - 16 ) ) ) ;
		//
		// System.out.println ( "获取当月第一天日期:" + DateUtil.format ( firstDayOfMonth
		// ( ) ) ) ;
		// System.out.println ( "获取当月最后一天日期:" + DateUtil.format ( lastDayOfMonth
		// ( ) ) ) ;
		// System.out.println ( "获取上个月第一天日期:" + DateUtil.format (
		// firstDayOfPreviousMonth ( ) ) ) ;
		// System.out.println ( "获取上个月最后一天日期:" + DateUtil.format (
		// lastDayOfPreviousMonth ( ) ) ) ;
		// System.out.println ( "获取下个月第一天日期:" + DateUtil.format (
		// firstDayOfNextMonth ( ) ) ) ;
		// System.out.println ( "获取下个月最后一天日期:" + DateUtil.format (
		// lastDayOfNextMonth ( ) ) ) ;
		//
		// System.out.println ( "获取当年第一天日期:" + DateUtil.format ( firstDayOfYear
		// ( ) ) ) ;
		// System.out.println ( "获取当年最后一天日期:" + DateUtil.format ( lastDayOfYear
		// ( ) ) ) ;
		// System.out.println ( "获取上个年第一天日期:" + DateUtil.format (
		// firstDayOfPreviousYear ( ) ) ) ;
		// System.out.println ( "获取上个年最后一天日期:" + DateUtil.format (
		// lastDayOfPreviousYear ( ) ) ) ;
		// System.out.println ( "获取下个年第一天日期:" + DateUtil.format (
		// firstDayOfNextYear ( ) ) ) ;
		// System.out.println ( "获取下个年最后一天日期:" + DateUtil.format (
		// lastDayOfNextYear ( ) ) ) ;
		//
		// System.out.println ( "按小时取整:" + DateUtil.format ( DateUtil.roundHour
		// ( new Date ( ) , 1 ) ) ) ;
		// System.out.println ( "按分钟取整:" + DateUtil.format ( DateUtil.roundMin (
		// new Date ( ) , 5 ) ) ) ;
		//
		// System.out.println ( DateUtil.format ( DateUtil.minOfMonth ( new Date
		// ( ) ) ) ) ;
		//
		// System.out.println ( DateUtil.format ( DateUtil.maxOfMonth ( new Date
		// ( ) ) ) ) ;
	}

}
